<%@ page import="com.example.entity.User" %>
<%--
  Created by IntelliJ IDEA.
  User: sansanmiaokou
  Date: 2025/11/20
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录结果</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        .result-container {
            background: white;
            border-radius: 15px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            padding: 40px;
            width: 100%;
            max-width: 500px;
            text-align: center;
        }
        .success-icon {
            font-size: 4rem;
            color: #28a745;
            margin-bottom: 20px;
        }
        .error-icon {
            font-size: 4rem;
            color: #dc3545;
            margin-bottom: 20px;
        }
        .result-title {
            font-weight: 600;
            margin-bottom: 15px;
        }
        .result-message {
            font-size: 1.1rem;
            margin-bottom: 25px;
            line-height: 1.6;
        }
        .btn-return {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            border-radius: 10px;
            padding: 12px 30px;
            font-weight: 600;
            transition: all 0.3s ease;
            text-decoration: none;
            color: white;
            display: inline-block;
        }
        .btn-return:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
            color: white;
        }
        .user-info {
            background-color: #f8f9fa;
            border-radius: 10px;
            padding: 20px;
            margin: 20px 0;
            text-align: left;
        }
        .user-info-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid #e9ecef;
        }
        .user-info-item:last-child {
            margin-bottom: 0;
            padding-bottom: 0;
            border-bottom: none;
        }
        .user-info-label {
            font-weight: 600;
            color: #495057;
        }
        .user-info-value {
            color: #6c757d;
        }
    </style>
</head>
<body>
<%
    User user = new User(request.getParameter("username"), request.getParameter("password"), "man");
    boolean isLoginSuccess = user.getUsername().equals("zhangsan") && user.getPassword().equals("123456");
%>

<div class="result-container">
    <% if (isLoginSuccess) { %>
    <div class="success-icon">
        <i class="bi bi-check-circle-fill"></i>
    </div>
    <h2 class="result-title text-success">登录成功！</h2>
    <p class="result-message text-muted">欢迎回来，<%= user.getUsername() %>！您已成功登录系统。</p>

    <div class="user-info">
        <h5 class="mb-3"><i class="bi bi-person-lines-fill"></i> 用户信息</h5>
        <div class="user-info-item">
            <span class="user-info-label">用户名：</span>
            <span class="user-info-value"><%= user.getUsername() %></span>
        </div>
        <div class="user-info-item">
            <span class="user-info-label">性别：</span>
            <span class="user-info-value"><%= user.getSex() %></span>
        </div>
        <div class="user-info-item">
            <span class="user-info-label">登录时间：</span>
            <span class="user-info-value"><%= new java.util.Date() %></span>
        </div>
    </div>

    <div class="alert alert-success" role="alert">
        <i class="bi bi-info-circle"></i> 您现在可以访问系统的所有功能。
    </div>

    <% } else { %>
    <div class="error-icon">
        <i class="bi bi-x-circle-fill"></i>
    </div>
    <h2 class="result-title text-danger">登录失败！</h2>
    <p class="result-message text-muted">抱歉，您输入的用户名或密码不正确。</p>

    <div class="alert alert-danger" role="alert">
        <i class="bi bi-exclamation-triangle"></i> 请检查您的用户名和密码，然后重试。
    </div>

    <div class="user-info">
        <h5 class="mb-3"><i class="bi bi-person-lines-fill"></i> 登录尝试</h5>
        <div class="user-info-item">
            <span class="user-info-label">尝试的用户名：</span>
            <span class="user-info-value"><%= user.getUsername() %></span>
        </div>
        <div class="user-info-item">
            <span class="user-info-label">尝试的密码：</span>
            <span class="user-info-value">
                        <%
                            String maskedPassword = "";
                            for (int i = 0; i < user.getPassword().length(); i++) {
                                maskedPassword += "*";
                            }
                        %>
                        <%= maskedPassword %>
                    </span>
        </div>
    </div>
    <% } %>

    <div class="mt-4">
        <a href="index.jsp" class="btn-return">
            <i class="bi bi-arrow-left-circle"></i> 返回登录
        </a>
    </div>
</div>

<!-- Bootstrap JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
